home *** CD-ROM | disk | FTP | other *** search
/ Nejlepší České Hry / Nej české hry.iso / hry / airhockey / airhockey.exe / scripts / frame_1 / DoAction_2.as next >
Text File  |  2004-11-25  |  5KB  |  159 lines

  1. function rhex(num)
  2. {
  3.    str = "";
  4.    j = 0;
  5.    while(3 >= j)
  6.    {
  7.       str += hex_chr.charAt(Math.bitAND(num >> j * 8 + 4,15)) + hex_chr.charAt(Math.bitAND(num >> j * 8,15));
  8.       j++;
  9.    }
  10.    return str;
  11. }
  12. function str2blks_MD5(str)
  13. {
  14.    nblk = (str.length + 8 >> 6) + 1;
  15.    blks = new Array(nblk * 16);
  16.    i = 0;
  17.    while(i < nblk * 16)
  18.    {
  19.       blks[i] = 0;
  20.       i++;
  21.    }
  22.    i = 0;
  23.    while(i < str.length)
  24.    {
  25.       blks[i >> 2] |= str.charCodeAt(i) << i % 4 * 8;
  26.       i++;
  27.    }
  28.    blks[i >> 2] |= 128 << i % 4 * 8;
  29.    blks[nblk * 16 - 2] = str.length * 8;
  30.    return blks;
  31. }
  32. function addme(x, y)
  33. {
  34.    var lsw = Math.bitAND(x,65535) + Math.bitAND(y,65535);
  35.    var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  36.    return msw << 16 | Math.bitAND(lsw,65535);
  37. }
  38. function rol(num, cnt)
  39. {
  40.    return num << cnt | num >>> 32 - cnt;
  41. }
  42. function cmn(q, a, b, x, s, t)
  43. {
  44.    return addme(rol(addme(addme(a,q),addme(x,t)),s),b);
  45. }
  46. function ff(a, b, c, d, x, s, t)
  47. {
  48.    return cmn(Math.bitAND(b,c) | Math.bitAND(~b,d),a,b,x,s,t);
  49. }
  50. function gg(a, b, c, d, x, s, t)
  51. {
  52.    return cmn(Math.bitAND(b,d) | Math.bitAND(c,~d),a,b,x,s,t);
  53. }
  54. function hh(a, b, c, d, x, s, t)
  55. {
  56.    return cmn(b ^ c ^ d,a,b,x,s,t);
  57. }
  58. function ii(a, b, c, d, x, s, t)
  59. {
  60.    return cmn(c ^ (b | ~d),a,b,x,s,t);
  61. }
  62. function md5(str)
  63. {
  64.    x = str2blks_MD5(str);
  65.    a = 1732584193;
  66.    b = -271733879;
  67.    c = -1732584194;
  68.    d = 271733878;
  69.    i = 0;
  70.    while(i < x.length)
  71.    {
  72.       olda = a;
  73.       oldb = b;
  74.       oldc = c;
  75.       oldd = d;
  76.       a = ff(a,b,c,d,x[i + 0],7,-680876936);
  77.       d = ff(d,a,b,c,x[i + 1],12,-389564586);
  78.       c = ff(c,d,a,b,x[i + 2],17,606105819);
  79.       b = ff(b,c,d,a,x[i + 3],22,-1044525330);
  80.       a = ff(a,b,c,d,x[i + 4],7,-176418897);
  81.       d = ff(d,a,b,c,x[i + 5],12,1200080426);
  82.       c = ff(c,d,a,b,x[i + 6],17,-1473231341);
  83.       b = ff(b,c,d,a,x[i + 7],22,-45705983);
  84.       a = ff(a,b,c,d,x[i + 8],7,1770035416);
  85.       d = ff(d,a,b,c,x[i + 9],12,-1958414417);
  86.       c = ff(c,d,a,b,x[i + 10],17,-42063);
  87.       b = ff(b,c,d,a,x[i + 11],22,-1990404162);
  88.       a = ff(a,b,c,d,x[i + 12],7,1804603682);
  89.       d = ff(d,a,b,c,x[i + 13],12,-40341101);
  90.       c = ff(c,d,a,b,x[i + 14],17,-1502002290);
  91.       b = ff(b,c,d,a,x[i + 15],22,1236535329);
  92.       a = gg(a,b,c,d,x[i + 1],5,-165796510);
  93.       d = gg(d,a,b,c,x[i + 6],9,-1069501632);
  94.       c = gg(c,d,a,b,x[i + 11],14,643717713);
  95.       b = gg(b,c,d,a,x[i + 0],20,-373897302);
  96.       a = gg(a,b,c,d,x[i + 5],5,-701558691);
  97.       d = gg(d,a,b,c,x[i + 10],9,38016083);
  98.       c = gg(c,d,a,b,x[i + 15],14,-660478335);
  99.       b = gg(b,c,d,a,x[i + 4],20,-405537848);
  100.       a = gg(a,b,c,d,x[i + 9],5,568446438);
  101.       d = gg(d,a,b,c,x[i + 14],9,-1019803690);
  102.       c = gg(c,d,a,b,x[i + 3],14,-187363961);
  103.       b = gg(b,c,d,a,x[i + 8],20,1163531501);
  104.       a = gg(a,b,c,d,x[i + 13],5,-1444681467);
  105.       d = gg(d,a,b,c,x[i + 2],9,-51403784);
  106.       c = gg(c,d,a,b,x[i + 7],14,1735328473);
  107.       b = gg(b,c,d,a,x[i + 12],20,-1926607734);
  108.       a = hh(a,b,c,d,x[i + 5],4,-378558);
  109.       d = hh(d,a,b,c,x[i + 8],11,-2022574463);
  110.       c = hh(c,d,a,b,x[i + 11],16,1839030562);
  111.       b = hh(b,c,d,a,x[i + 14],23,-35309556);
  112.       a = hh(a,b,c,d,x[i + 1],4,-1530992060);
  113.       d = hh(d,a,b,c,x[i + 4],11,1272893353);
  114.       c = hh(c,d,a,b,x[i + 7],16,-155497632);
  115.       b = hh(b,c,d,a,x[i + 10],23,-1094730640);
  116.       a = hh(a,b,c,d,x[i + 13],4,681279174);
  117.       d = hh(d,a,b,c,x[i + 0],11,-358537222);
  118.       c = hh(c,d,a,b,x[i + 3],16,-722521979);
  119.       b = hh(b,c,d,a,x[i + 6],23,76029189);
  120.       a = hh(a,b,c,d,x[i + 9],4,-640364487);
  121.       d = hh(d,a,b,c,x[i + 12],11,-421815835);
  122.       c = hh(c,d,a,b,x[i + 15],16,530742520);
  123.       b = hh(b,c,d,a,x[i + 2],23,-995338651);
  124.       a = ii(a,b,c,d,x[i + 0],6,-198630844);
  125.       d = ii(d,a,b,c,x[i + 7],10,1126891415);
  126.       c = ii(c,d,a,b,x[i + 14],15,-1416354905);
  127.       b = ii(b,c,d,a,x[i + 5],21,-57434055);
  128.       a = ii(a,b,c,d,x[i + 12],6,1700485571);
  129.       d = ii(d,a,b,c,x[i + 3],10,-1894986606);
  130.       c = ii(c,d,a,b,x[i + 10],15,-1051523);
  131.       b = ii(b,c,d,a,x[i + 1],21,-2054922799);
  132.       a = ii(a,b,c,d,x[i + 8],6,1873313359);
  133.       d = ii(d,a,b,c,x[i + 15],10,-30611744);
  134.       c = ii(c,d,a,b,x[i + 6],15,-1560198380);
  135.       b = ii(b,c,d,a,x[i + 13],21,1309151649);
  136.       a = ii(a,b,c,d,x[i + 4],6,-145523070);
  137.       d = ii(d,a,b,c,x[i + 11],10,-1120210379);
  138.       c = ii(c,d,a,b,x[i + 2],15,718787259);
  139.       b = ii(b,c,d,a,x[i + 9],21,-343485551);
  140.       a = addme(a,olda);
  141.       b = addme(b,oldb);
  142.       c = addme(c,oldc);
  143.       d = addme(d,oldd);
  144.       i += 16;
  145.    }
  146.    return rhex(a) + rhex(b) + rhex(c) + rhex(d);
  147. }
  148. var hex_chr = "0123456789abcdef";
  149. Math.bitAND = function(a, b)
  150. {
  151.    if(a < 0 && b < 0)
  152.    {
  153.       var lsb = a & 1 & (b & 1);
  154.       var msb31 = a >>> 1 & b >>> 1;
  155.       return msb31 << 1 | lsb;
  156.    }
  157.    return a & b;
  158. };
  159.